

if(request.method!=='POST'){

		response.redirect("/home",request,response);
	    response.end();

}else{
   
	var boardName=request.parameters["boardName"];
	var subject=request.parameters["subject"];
	var text=request.parameters["text"];
	var color=request.parameters["color"];
	
	var session=request.getSession();

		if(typeof session==='undefined'){


		var output = {redirect: "/login",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
	
	}else if(!session.LoggedIn){
		var output = {redirect: "/login",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();

	}else{



	var user=session.user;

	var boardController=request.require("./boardController");
	boardController.setMsg(boardName,subject,text,color,user.username,response,cb);
	}
}

function cb(boardname,response){

	
	if(boardName){
	
		var url="/board?name="+boardName;
		var output = {redirect:url ,msg:undefined};
	
		response.headers["Content-Type"]="application/json";
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
		
	}else{
	
	var output = {redirect: "/home",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
	}
	
	
}



